--RedZoneRPG
--By Kylegar

include("sv_accounts.lua")
include("shared.lua")
include("shd_itemfunctions.lua")

--[[
DEBUG FUNCTIONS

Made for Debugging the game

Debug Functions are availble to Everyone.  If it gets out of hand, Ill disable these


]]--
function rz_debug_createaccount(player , command, args)
	createaccount(player)
end
concommand.Add("rz_debug_createaccount" , rz_debug_createaccount)

function rz_debug_saveaccount(player , command, args)

	saveaccount(player)

end
concommand.Add("rz_debug_saveaccount" , rz_debug_saveaccount)

function rz_debug_loadaccount(player , command, args)

	loadaccount(player)

end
concommand.Add("rz_debug_loadaccount" , rz_debug_loadaccount)

--this is only usefull if you have physical access to the server, or can see the server's console.  
function rz_debug_showvars(player , command , args)
	--for k , v in pairs(player.GetAll()) do	
		Msg("Name: "..player:GetName().."\n")
		Msg("Level: "..player:GetLevel().."\n")
		Msg("XpForNextLevel: "..player:GetXPForNextLevel().."\n")
		Msg("XP: "..player:GetXP().."\n")
		Msg("SP: "..player:GetSkillPoints().."\n")
		Msg("MaxHealth: "..player:GetPlayerMaxHealth().."\n")
		Msg("MaxArmor: "..player:GetPlayerMaxArmor().."\n")
		for k,v in pairs(BaseClasses) do
			Msg(v.." Level: "..player:GetBaseSkillLevel(v).."\n")
		end
			
		
	--end
end
concommand.Add("rz_debug_showvars" , rz_debug_showvars)

function rz_dubug_saveallplayeraccounts()
	for k , v in pairs(player.GetAll()) do
		saveaccount(v)
	end

end
concommand.Add("rz_debug_saveallplayeraccounts" , rz_debug_saveallplayeraccounts)

function rz_debug_DoSkillChange(ply)
	ply:DoBaseSkillChange()
end
concommand.Add("rz_debug_DoSkillChange" , rz_debug_DoSkillChange)

function rz_debug_ShowInv(ply)
	for k,v in pairs(ply:GetInv()) do
		Msg("ItemID: "..v.ItemID.." name: "..v.Printname.." Class: "..v.Classname.." Ammount: "..v.Ammount.."\n")
	end
end
concommand.Add("rz_debug_ShowInv" , rz_debug_ShowInv)

function rz_debug_CreateItem(ply,command,args)
	rzItem.Create(args[1])
end
concommand.Add("rz_debug_CreateItem", rz_debug_CreateItem)

function rz_debug_ShowRegisteredItems()
	ShowItemClasses()
end
concommand.Add("rz_debug_ShowRegisteredItems",rz_debug_ShowRegisteredItems)

function rz_debug_ClearInv(ply)
	for k,v in pairs(ply:GetInv()) do
		rzItem.RemoveItem(v)
	end
end
concommand.Add("rz_debug_ClearInv",rz_debug_ClearInv)

--[[
CHEAT FUNCTIONS

These are mostly for testing, but could be usefull.  ADMINS ONLY 

]]--

function rz_cheat_giveweapons(pl)

	pl:GiveAmmo( 255,"Pistol") 
 	pl:GiveAmmo( 90,"SMG1") 
 	pl:GiveAmmo( 1,	"grenade") 
 	pl:GiveAmmo( 32,"Buckshot") 
 	pl:GiveAmmo( 16,"357") 
	pl:GiveAmmo( 90,"AR2")
 	 
 	
 	pl:Give( "weapon_crowbar" ) 
 	pl:Give( "weapon_pistol" ) 
 	pl:Give( "weapon_smg1" ) 
 	pl:Give( "weapon_frag" ) 
 	pl:Give("weapon_rpg")
 	pl:Give("weapon_ar2") 
	--pl:Give("weapon_ak47")
	--pl:Give("weapon_m4")
	pl:Give("weapon_shotgun")

end
concommand.Add("rz_cheat_giveweapons" , rz_cheat_giveweapons)

function rz_cheat_levelup(pl)
	if(pl:IsAdmin()) then
		pl:LevelUp()
	else 
		pl:PrintMessage(HUD_PRINTTALK, "You Cant Do That")
	end
end
concommand.Add("rz_cheat_levelup" , rz_cheat_levelup)

function rz_cheat_addxp(pl,cmd,args)
	if(pl:IsAdmin()) then
		pl:AddXP(args[1])
	else
	 pl:PrintMessage(HUD_PRINTTALK, "You Cant Do That")
	end
end
concommand.Add("rz_cheat_addxp" , rz_cheat_addxp)

function rz_cheat_giveitem(pl,cmd,args)
	Msg(args[1].."\n")
	local item = rzItem.Create(args[1])
	if(item)then
		pl:AddToInv(item)
	else
		Msg("Nil?\n")
	end
	
	
end
concommand.Add("rz_cheat_giveitem", rz_cheat_giveitem)


--[[
GAME FUNCTIONS

Availible to Everyone

These allow you to change your stats.  These are called through VGUI Panels, 
Theres are mostly for adding skill points and stuff like that

They are harmless to be used, Because they are being used in the VGUI Panels
]]--


function rz_game_AddBaseSkillLevel(player,cmd,args)
	if(player:HasSkillPoints()) then
		player:AddBaseSkillLevel(tostring(args[1]) , tonumber(args[2]))
		player:AddSkillPoints((tonumber(args[2]) * -1))
		player:DoBaseSkillChange(args[1])
		player:PrintMessage(HUD_PRINTTALK, "You have leveled up "..args[1].." to level "..player:GetBaseSkillLevel(args[1]))
		return
	end
	player:PrintMessage(HUD_PRINTTALK, "Not Enough Skillpoints")
	
end
concommand.Add("rz_game_AddBaseSkillLevel", rz_game_AddBaseSkillLevel)

function rz_game_PickupItem(player,cmd,args)
	


end
concommand.Add("rz_game_PickupItem",rz_game_PickupItem)

function rz_game_UseItem(player,cmd,args)
	local itemuse = rzItem.FindByItemID(args[1])
	if(ply == itemuse.Owner) then
		player:UseItem(itemuse)
		player:PrintMessage(HUD_PRINTTALK, "Used Item")
	else
		player:PrintMessage(HUD_PRINTTALK, "Not Your Item")
	end

end
concommand.Add("rz_game_UseItem",rz_game_UseItem)